﻿@{
    ViewBag.Title = "购买优惠券服务";
}

<script src="~/Scripts/v.js"></script>
<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>优惠券</strong>
        <li class=""><a href="@Url.Action("Management")">所有优惠券</a></li>
        @if (ViewBag.Market != null && ((Himall.Model.ActiveMarketServiceInfo)ViewBag.Market).MarketServiceRecordInfo.Max(a => a.EndTime) >= DateTime.Now.Date)
        {
            <li class=""><a href="@Url.Action("Add")">添加优惠券</a></li>
        }
        <li class="active"><a>购买服务</a></li>
        <em class="primary-btn">
            <span class="glyphicon glyphicon-question-sign"></span>
            <div class="primary">
                <h3>温馨提示：</h3>
                <span>1、</span><p>购买单位为月，您可以在所购买的周期内发布优惠券；</p>
                <span>2、</span><p>每月您需要支付 @ViewBag.Price.ToString("f2") 元 ;</p>
                <span>3、</span><p class="red">相关费用会在店铺的账期结算中扣除</p>
            </div>
        </em>
    </ul>
    <form id="form1" action="@Url.Action("BuyService")" method="post">
        <div class="form-horizontal">
            <div class="form-group">
                @if (null != ViewBag.EndDate)
                {
                    <label class="col-sm-2 control-label" for="">服务到期时间：</label>
                    <div class="col-sm-2 form-control-static"><b>@ViewBag.EndDate</b></div>
                    <div class="col-sm-6"><span class="help-default">每月您需要支付<b class="red"> @ViewBag.Price.ToString("f2") </b> 元，相关费用会在店铺的账期结算中扣除</span></div>
                }
                else
                {
                    <div class="col-sm-3 col-sm-offset-2 form-control-static red">您未购买优惠券服务</div>
                    <span>每月您需要支付 @ViewBag.Price.ToString("f2") 元</span>
                }
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="">购买数量：</label>
                <div class="col-sm-8"><input class="form-control input-sm " type="text" id="range" name="month" style="width:105px; display:inline-block" /> &nbsp; 月</div>
            </div>
            <div class="form-group">
                <div class="col-sm-3 col-sm-offset-2"><button type="submit" class="btn btn-primary">确认购买</button></div>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {
        $("#range").focus();
    });
    var a = v({
        form: 'form1',
        ajaxSubmit: true,
        beforeSubmit: function () {
            loadingobj = showLoading();
        },
        afterSubmit: function (data) {// 表单提交成功回调
            loadingobj.close();
            var d = data;
            if (d.success) {
                $.dialog.succeedTips("提交成功！", function () {
                    window.location.reload();
                }, 0.3);
            } else {
                $.dialog.errorTips(d.msg, '', 0.3);
            }
        }
    });
    a.add(
        {
            target: 'range',
            empty: true,
            ruleType: 'uint&&(value>0)&&(value<=3600)',// v.js规则验证
            error: '只能为数字，且只能是0到3600之间的整数!'
        });
</script>